OpenSSH の脆弱性 CVE-2024-6387 について Amazon Linux 2023 で対応してみた

OpenSSH の脆弱性 CVE-2024-6387 について Amazon Linux 2023 で対応してみた

Clock Icon2024.7.2

コーヒーが好きな emi です。

OpenSSH の脆弱性 CVE-2024-6387 が発表されました。Amazon Linux 2023 も対象でした。
個人検証環境の EC2 インスタンスに Amazon Linux 2023 がありましたので、アップデート対応をしました。

OpenSSH の脆弱性 CVE-2024-6387 の概要

脆弱性を悪用された場合、特権でリモートから認証なしの任意コード実行をされる恐れがある模様です。

https://blog.qualys.com/vulnerabilities-threat-research/2024/07/01/regresshion-remote-unauthenticated-code-execution-vulnerability-in-openssh-server

対応方法

根本対応

※これら以外の OS も脆弱性の対象となる可能性がございます。

回避策

  • 特定IPアドレスからのみを許可するアクセス制限
  • 「LoginGraceTime」(ログイン試行の接続時間)の設定値を 0(タイムアウトを無効)にする
    • ただし本設定はあくまで緩和策であり、この設定を行うことでサービス拒否(DoS)の影響を受ける恐れがあります。
    • CVE-2024-6387- Red Hat Customer Portal

Amazon Linux 2023 での修正アップデート

修正アップデート対応をする Amazon Linux 2023 のバージョン確認をします。
実行コマンド

cat /etc/os-release

▼実行結果

[ec2-user@ip-172-31-42-201 ~]$ cat /etc/os-release
NAME="Amazon Linux"
VERSION="2023"
ID="amzn"
ID_LIKE="fedora"
VERSION_ID="2023"
PLATFORM_ID="platform:al2023"
PRETTY_NAME="Amazon Linux 2023.3.20240304"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2023"
HOME_URL="https://aws.amazon.com/linux/amazon-linux-2023/"
DOCUMENTATION_URL="https://docs.aws.amazon.com/linux/"
SUPPORT_URL="https://aws.amazon.com/premiumsupport/"
BUG_REPORT_URL="https://github.com/amazonlinux/amazon-linux-2023"
VENDOR_NAME="AWS"
VENDOR_URL="https://aws.amazon.com/"
SUPPORT_END="2028-03-15"
[ec2-user@ip-172-31-42-201 ~]$ 

以下のコマンドでもバージョン確認できます。

[ec2-user@ip-172-31-42-201 ~]$ rpm -q system-release
system-release-2023.3.20240304-0.amzn2023.noarch
[ec2-user@ip-172-31-42-201 ~]$

現在の OpenSSH のバージョンを確認します。
実行コマンド

rpm -qa | grep openssh

▼実行結果

[ec2-user@ip-172-31-42-201 ~]$ rpm -qa | grep openssh
openssh-server-8.7p1-8.amzn2023.0.9.x86_64
openssh-8.7p1-8.amzn2023.0.9.x86_64
openssh-clients-8.7p1-8.amzn2023.0.9.x86_64
[ec2-user@ip-172-31-42-201 ~]$

修正アップデート

Amazon Linux 2023 は以下のコマンドを実行することで修正アップデートが可能です。

dnf update openssh --releasever 2023.5.20240701

https://alas.aws.amazon.com/AL2023/ALAS-2024-649.html

▼実行結果

[ec2-user@ip-172-31-42-201 ~]$ dnf update openssh --releasever 2023.5.20240701
Error: This command has to be run with superuser privileges (under the root user on most systems).
[ec2-user@ip-172-31-42-201 ~]$

おっと。権限が足りませんでした。再度 sudo を付けて再度実行します。

実行結果(クリックでトグルを展開)
[ec2-user@ip-172-31-42-201 ~]$ sudo dnf update openssh --releasever 2023.5.20240701
Amazon Linux 2023 repository                                                                                                                                 49 MB/s |  25 MB     00:00
Amazon Linux 2023 Kernel Livepatch repository                                                                                                                26 kB/s | 2.9 kB     00:00
Amazon Linux 2023 Kernel Livepatch repository                                                                                                                51 kB/s |  11 kB     00:00
Dependencies resolved.
============================================================================================================================================================================================
 Package                                        Architecture                          Version                                              Repository                                  Size
============================================================================================================================================================================================
Upgrading:
 openssh                                        x86_64                                8.7p1-8.amzn2023.0.11                                amazonlinux                                453 k
 openssh-clients                                x86_64                                8.7p1-8.amzn2023.0.11                                amazonlinux                                708 k
 openssh-server                                 x86_64                                8.7p1-8.amzn2023.0.11                                amazonlinux                                455 k

Transaction Summary
============================================================================================================================================================================================
Upgrade  3 Packages

Total download size: 1.6 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): openssh-8.7p1-8.amzn2023.0.11.x86_64.rpm                                                                                                             5.3 MB/s | 453 kB     00:00
(2/3): openssh-clients-8.7p1-8.amzn2023.0.11.x86_64.rpm                                                                                                     7.1 MB/s | 708 kB     00:00
(3/3): openssh-server-8.7p1-8.amzn2023.0.11.x86_64.rpm                                                                                                      4.3 MB/s | 455 kB     00:00
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                       9.5 MB/s | 1.6 MB     00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                    1/1
  Running scriptlet: openssh-8.7p1-8.amzn2023.0.11.x86_64                                                                                                                               1/6
  Upgrading        : openssh-8.7p1-8.amzn2023.0.11.x86_64                                                                                                                               1/6
  Upgrading        : openssh-clients-8.7p1-8.amzn2023.0.11.x86_64                                                                                                                       2/6
  Running scriptlet: openssh-clients-8.7p1-8.amzn2023.0.11.x86_64                                                                                                                       2/6
  Running scriptlet: openssh-server-8.7p1-8.amzn2023.0.11.x86_64                                                                                                                        3/6
  Upgrading        : openssh-server-8.7p1-8.amzn2023.0.11.x86_64                                                                                                                        3/6
  Running scriptlet: openssh-server-8.7p1-8.amzn2023.0.11.x86_64                                                                                                                        3/6
  Running scriptlet: openssh-server-8.7p1-8.amzn2023.0.9.x86_64                                                                                                                         4/6
  Cleanup          : openssh-server-8.7p1-8.amzn2023.0.9.x86_64                                                                                                                         4/6
  Running scriptlet: openssh-server-8.7p1-8.amzn2023.0.9.x86_64                                                                                                                         4/6
  Running scriptlet: openssh-clients-8.7p1-8.amzn2023.0.9.x86_64                                                                                                                        5/6
  Cleanup          : openssh-clients-8.7p1-8.amzn2023.0.9.x86_64                                                                                                                        5/6
  Cleanup          : openssh-8.7p1-8.amzn2023.0.9.x86_64                                                                                                                                6/6
  Running scriptlet: openssh-8.7p1-8.amzn2023.0.9.x86_64                                                                                                                                6/6
  Verifying        : openssh-8.7p1-8.amzn2023.0.11.x86_64                                                                                                                               1/6
  Verifying        : openssh-8.7p1-8.amzn2023.0.9.x86_64                                                                                                                                2/6
  Verifying        : openssh-clients-8.7p1-8.amzn2023.0.11.x86_64                                                                                                                       3/6
  Verifying        : openssh-clients-8.7p1-8.amzn2023.0.9.x86_64                                                                                                                        4/6
  Verifying        : openssh-server-8.7p1-8.amzn2023.0.11.x86_64                                                                                                                        5/6
  Verifying        : openssh-server-8.7p1-8.amzn2023.0.9.x86_64                                                                                                                         6/6

Upgraded:
  openssh-8.7p1-8.amzn2023.0.11.x86_64                     openssh-clients-8.7p1-8.amzn2023.0.11.x86_64                     openssh-server-8.7p1-8.amzn2023.0.11.x86_64

Complete!
[ec2-user@ip-172-31-42-201 ~]$

修正アップデート後の OpenSSH のバージョンを確認します。
実行コマンド

rpm -qa | grep openssh

▼実行結果

[ec2-user@ip-172-31-42-201 ~]$ rpm -qa | grep openssh
openssh-8.7p1-8.amzn2023.0.11.x86_64
openssh-clients-8.7p1-8.amzn2023.0.11.x86_64
openssh-server-8.7p1-8.amzn2023.0.11.x86_64
[ec2-user@ip-172-31-42-201 ~]$

ALAS-2024-649 の「New Packages:」に含まれるバージョンが表示されています。修正アップデートできたことが確認できました。

emiki_openssh-cve-2024-6387-amazon-linux-2023

参考

Amazon Linux 1、Amazon Linux 2 は影響なし
https://explore.alas.aws.amazon.com/CVE-2024-6387.html

https://piyolog.hatenadiary.jp/entry/2024/07/02/032122

この記事をシェアする

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.